package com.bawei.module_home.discovery.adapter

import com.bawei.module_home.R
import com.bawei.module_home.discovery.adapter.provider.*
import com.bawei.module_home.discovery.entity.DiscoveryEntity
import com.chad.library.adapter.base.BaseProviderMultiAdapter

/**
 * @Author : yaotianxue
 * @Time : On 2023/5/29 19:24
 * @Description : DiscoveryAdapter
 */
class DiscoveryAdapter:BaseProviderMultiAdapter<DiscoveryEntity.Item>() {

    init {
        addItemProvider(TopBannerProvider(DisCoverItemType.TOP_BANNER_VIEW, R.layout.home_item_top_banner_view)) //轮播图
        addItemProvider(CategoryCardProvider(DisCoverItemType.CATEGORY_CARD_VIEW,R.layout.home_item_category_card_view))//热门分类
        addItemProvider(CardListProvider(DisCoverItemType.SUBJECT_CARD_VIEW,R.layout.home_item_category_card_view))//专题测滑和热门分类一样
        addItemProvider(TitleProvider(DisCoverItemType.TITLE_VIEW,R.layout.home_item_title_left_right_view))//本周榜单
        addItemProvider(VideoCardProvider(DisCoverItemType.VIDEO_CARD_VIEW,R.layout.home_item_video_card_view))//视频item
        addItemProvider(BriefCardProvider(DisCoverItemType.THEME_CARD_VIEW,R.layout.home_item_brief_card_view)) //推荐主题item
        addItemProvider(EmptyProvider(DisCoverItemType.EMPTY_VIEW,R.layout.home_item_empty))//

    }
    override fun getItemType(data: List<DiscoveryEntity.Item>, position: Int): Int {
      return  when(data[position].type){
            DisCoverItemType.TOP_BANNER_VIEW_STR -> DisCoverItemType.TOP_BANNER_VIEW//轮播图
            DisCoverItemType.CATEGORY_CARD_VIEW_STR -> DisCoverItemType.CATEGORY_CARD_VIEW //热门分类
            DisCoverItemType.SUBJECT_CARD_VIEW_STR -> DisCoverItemType.SUBJECT_CARD_VIEW //专题策划
            DisCoverItemType.TITLE_VIEW_STR -> DisCoverItemType.TITLE_VIEW  //标题
            DisCoverItemType.VIDEO_CARD_VIEW_STR -> DisCoverItemType.VIDEO_CARD_VIEW //视频item
            DisCoverItemType.THEME_CARD_VIEW_STR -> DisCoverItemType.THEME_CARD_VIEW //推荐主题item

            else -> DisCoverItemType.EMPTY_VIEW
      }


    }


}